package com.cqc.suertextview01;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.Toast;

import com.allen.library.SuperTextView;

/**
 * Created by ${cqc} on 2017/9/12.
 */

public class SuperTextViewActivity extends AppCompatActivity {

    private Context context = this;
    private SuperTextView superTextView;
    private SuperTextView stv_cb2;
    private SuperTextView stv_sb;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_super_text_view);
        superTextView = (SuperTextView) findViewById(R.id.superTextView);

        superTextView.setOnSuperTextViewClickListener(new SuperTextView.OnSuperTextViewClickListener() {
            @Override
            public void onClickListener(SuperTextView superTextView) {
                Toast.makeText(context, "SuperTextView", Toast.LENGTH_SHORT).show();
            }
        }).setLeftTopTvClickListener(new SuperTextView.OnLeftTopTvClickListener() {
            @Override
            public void onClickListener() {
                Toast.makeText(context, "左上", Toast.LENGTH_SHORT).show();
            }
        }).setLeftTvClickListener(new SuperTextView.OnLeftTvClickListener() {
            @Override
            public void onClickListener() {
                Toast.makeText(context, "左", Toast.LENGTH_SHORT).show();
            }
        }).setLeftBottomTvClickListener(new SuperTextView.OnLeftBottomTvClickListener() {
            @Override
            public void onClickListener() {
                Toast.makeText(context, "左下", Toast.LENGTH_SHORT).show();
            }
        });


        SuperTextView stv_cb = (SuperTextView) findViewById(R.id.stv_cb);
        stv_cb.setCheckBoxCheckedChangeListener(new SuperTextView.OnCheckBoxCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                compoundButton.setChecked(b);
                Toast.makeText(context, b + "", Toast.LENGTH_SHORT).show();
            }
        });

        stv_cb2 = (SuperTextView) findViewById(R.id.stv_cb2);
        stv_cb2.setCbChecked(true);
        stv_cb2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                boolean cbisChecked = stv_cb2.getCbisChecked();
                Toast.makeText(context, cbisChecked + "", Toast.LENGTH_SHORT).show();
            }
        });

        stv_sb = (SuperTextView) findViewById(R.id.stv_sb);
        stv_sb.setOnSuperTextViewClickListener(new SuperTextView.OnSuperTextViewClickListener() {
            @Override
            public void onClickListener(SuperTextView superTextView) {
                boolean switchIsChecked = stv_sb.getSwitchIsChecked();
                Toast.makeText(context, switchIsChecked + "", Toast.LENGTH_SHORT).show();
            }
        });
    }
}
